#include "burstManager.h"

burstManager* burstManager::_instance = 0;

burstManager* burstManager::Instance()
{
	if (_instance == NULL)
	{
		_instance = new burstManager();
	}
	return _instance;
}

burstManager::burstManager()
{
	sum = 0;
}

void burstManager::updata()
{
	for (list<Burst*>::iterator itor = manager.begin();
		itor != manager.end();)
	{
		if ((*itor)->checkRemove())
		{
			delete *itor;
			itor = manager.erase(itor);
		}else
		{
			(*itor)->updata();
			itor++;
		}
	}
	sum = manager.size();
}

void burstManager::add(Burst* b)
{
	manager.push_back(b);
}

void burstManager::draw()
{
	for (list<Burst*>::iterator itor = manager.begin();
		itor != manager.end(); itor++)
	{
		(*itor)->draw();
	}
}

void burstManager::clear()
{
	for (list<Burst*>::iterator itor = manager.begin();
		itor != manager.end();)
	{
		delete *itor;
	}
	list<Burst*> t;
	manager.swap(t);
}